<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Profiler
 *
 * @author zelic
 */
class Profiler {
    static $entries=array();
    public static function start($entryName){
        Profiler::$entries[$entryName]["start"] = microtime(true);
    }
    
    public static function end($entryName){
        Profiler::$entries[$entryName]["end"] = microtime(true);
        Profiler::$entries[$entryName]["elapsed"] = Profiler::$entries[$entryName]["end"]-Profiler::$entries[$entryName]["start"];
        var_dump(Profiler::$entries[$entryName]["elapsed"]);
    }
    
    public static function output(){
        echo "<table cellpadding=\"0\" style=\"border: 1px #000 solid; text-align: center;\">";
        echo "  <tr style=\"background: #CCC; color: #000;\">";
        echo "      <th>No.</th>";
        echo "      <th>Job</th>";
        echo "      <th>Executing time</th>";
        echo "  </tr>";
        $index = 1;
        foreach (Profiler::$entries as $name=>$value){
            echo "<tr>";
            echo "  <td>$index</td>";
            echo "  <td>$name</td>";
            echo "  <td>".$value["elapsed"]."</td>";
            echo "</tr>";
            $index++;
        }
        echo "</table>";
    }
}

?>
